require 'securerandom'
class AuthToken < ActiveRecord::Base
  attr_accessible :token, :client_identifier, :client_type, :expired_timestamp

  before_create do
    self.token = AuthToken.generate_auth_token
    self.expired_timestamp = Time.now.to_i + 30 * 24 * 3600
  end


  private 
    def AuthToken.generate_auth_token
      # will generate a random hex string whose length of 32
      SecureRandom.hex 16
    end
end
